package com.hzgj.bcl.soa.controller.logic;

import com.hzgj.bcl.soa.command.ClientCommand;
import com.hzgj.bcl.soa.command.CommandsInitializer;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

/**
 * Created by warning5 on 2017/3/29.
 */
public class NodeClientsLogic implements PageLogic {
    @Override
    public List<String> getPages() {
        return Arrays.asList("node-clients");
    }

    @Override
    public void handle(HttpServletRequest request, Model model) {
        ClientCommand soaCommand = CommandsInitializer.getCommand(CommandsInitializer.CLIENT_COMMAND);
        String address = request.getParameter("address");
        model.addAttribute("cs", soaCommand.getClientsByAddress(address));
        model.addAttribute("address", address);
        model.addAttribute("pools", soaCommand.getClientPoolInfo(address.split(":")));
    }
}
